//
//  SYBaseCell.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2020/8/26.
//  Copyright © 2020 叁拾叁. All rights reserved.
//

import UIKit
import RxSwift

class SYBaseCell: UITableViewCell {
    
    let disposeBag = DisposeBag()
    
    weak var currentVC: SYBaseViewController!
    
    public var clickedClosure: ((Int) -> Void)?
    
    public var passParamsClosure: ((Any) -> Void)?
    
    public var lineView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xE6E6E6)
        return v
    }()

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        initViews()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    func initViews() {
        
    }
    
    func setPriceLb(_ price: String?) -> NSMutableAttributedString {
        let d: Double = Double(price ?? "0") ?? 0.0
        let priceStr = String(format: "%.2f", d)
        let firStr = "￥"
        let totalStr = "￥\(priceStr)"
        let attString = NSMutableAttributedString(string: totalStr)
        attString.yy_setColor(UIColor(hex: 0xF55035), range: NSRange(location: 0, length: firStr.count))
        attString.yy_setFont(13.autoFontSize(), range: NSRange(location: 0, length:firStr.count))
        attString.yy_setColor(UIColor(hex: 0xF55035), range: NSRange(location: firStr.count, length: totalStr.count - firStr.count))
        attString.yy_setFont(16.autoFontSize(), range: NSRange(location: firStr.count, length: totalStr.count - firStr.count))
        return attString
    }
}
